package com.ais.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

import com.ais.vo.Person;
@Repository("personDao")
public class PersonDao extends SqlMapClientDaoSupport{

    public PersonDao() {
        super();
    }

    public int deleteByPrimaryKey(Integer id) {
        Person _key = new Person();
        _key.setId(id);
        int rows = getSqlMapClientTemplate().delete("person.deleteByPrimaryKey", _key);
        return rows;
    }

    public void insert(Person record) {
        getSqlMapClientTemplate().insert("person.insert", record);
    }

    public void insertSelective(Person record) {
        getSqlMapClientTemplate().insert("person.insertSelective", record);
    }

    public Person selectByPrimaryKey(Integer id) {
        Person _key = new Person();
        _key.setId(id);
        Person record = (Person) getSqlMapClientTemplate().queryForObject("person.selectByPrimaryKey", _key);
        return record;
    }

    public int updateByPrimaryKeySelective(Person record) {
        int rows = getSqlMapClientTemplate().update("person.updateByPrimaryKeySelective", record);
        return rows;
    }

    public int updateByPrimaryKey(Person record) {
        int rows = getSqlMapClientTemplate().update("person.updateByPrimaryKey", record);
        return rows;
    }

	public List<Person> selectPersons(Person person) {
		return getSqlMapClientTemplate().queryForList("person.selectPersons", person);
	}

	public boolean login(String userName, String password) {
		Map map = new HashMap();
		map.put("userName", userName);
		map.put("password", password);
		return (Integer)getSqlMapClientTemplate().queryForObject("person.login",map)>0;
	}
}